package com.sgb.kjwl.view.widget;

import android.content.Context;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.widget.ImageView;

import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.transport.GoodsInfoEntity3;
import com.sgb.kjwl.view.ui.adapter.transport.GoodsMessageTypeAdapter3;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;

import java.util.ArrayList;
import java.util.List;

public class GoodsMessagePopWindow3 extends BasePopWindow {


    public GoodsMessagePopWindow3(Context context) {
        super(context);
    }

    @Override
    protected int popLayout() {
        return R.layout.popwindow_goods_message3;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        ImageView iv_close = holder.getPop().findViewById(R.id.goods_message_close);
        RecyclerView messageList = holder.getPop().findViewById(R.id.goods_message_list);
        iv_close.setOnClickListener(view -> {dissMiss();});

        List<GoodsInfoEntity3> list = new ArrayList<>();
        int page = 2;
        for(int i=0;i<10;i++){
            GoodsInfoEntity3 needsEntity = new GoodsInfoEntity3();
            needsEntity.setStartStation("北京 朝阳_"+(i*page));
            needsEntity.setEndStation("上海 黄埔新区_"+(i*page));
            needsEntity.setGoodsName("金属刚才/10吨_"+(i*page));
            needsEntity.setDistances("已上架");
            if(i%2 == 0){
                needsEntity.setGoodsPrice("success");
            }else{
                needsEntity.setGoodsPrice("fail");
            }
            needsEntity.setGoodsType("2020-3-20/高栏/15m");

            list.add(needsEntity);
        }

        GoodsMessageTypeAdapter3 adapter3 = new GoodsMessageTypeAdapter3(mContext,list);
        messageList.setLayoutManager(new GridLayoutManager(mContext,1));
        messageList.setAdapter(adapter3);

    }
}
